import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'dart:ui' as ui;

import 'package:flutter3demo/CustomRootElement.dart';

import '../common_util.dart';


void main() {
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home:Material(child: TestPage()),
    );
  }
}

class TestPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return TestPageState();
  }

}
class TestPageState extends State<TestPage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constraints) {
        print("asdasdasdasdasdasdasdasd");
///系统发送通知的条件 if (_oldSize != null && size != _oldSize) {

        return NotificationListener<SizeChangedLayoutNotification>(
          onNotification: (SizeChangedLayoutNotification notification) {
            print("notification ========$notification");
            // notification.
            return false;
          },
          child: SizeChangedLayoutNotifier(
            child: Container(
              // width: constraints.maxWidth,
              // height: constraints.maxHeight,
              decoration: BoxDecoration(
                color: CommonUtil.randomColor(),
              ),
              alignment: AlignmentDirectional.centerEnd,
              child: Container(color: Colors.green,child: Text("adasdasd")),
            ),
          ),
        );
      },
    );
  }
}

